package com.zy.mybatisdemo.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: zhangy
 * @Date: 2018/10/3 23:13
 * @Description:
 */

@Configuration
public class FilterBeanConfig {

    /*
    * 1. 重构filter
    * 2. 配置拦截urlPattern
    * 3. 利用FilterRegistrationBean进行包装
    */

    @Bean
    public FilterRegistrationBean logFilter(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new LogFilter());
        List<String> urlList = new ArrayList<>();
        //拦截所有的url请求
        urlList.add("*");
        filterRegistrationBean.setUrlPatterns(urlList);
        return filterRegistrationBean;

    }

}
